package com.ssyx.common.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName:LoginMvcConfigurerAdapter
 * Description:
 * 设置自定义拦截器路径
 * @Author kay
 * @Create 2024/5/15 11:11
 * @Version 1.0
 */
@Component
public class LoginMvcConfigurerAdapter implements WebMvcConfigurer {

    @Autowired
    private UserLoginInterceptor userLoginInterceptor;

    //拦截器注册
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/api/**") // 与用户相关的请求,拦截其路径
                .excludePathPatterns("/api/user/weixin/wxLogin/*"); //除了登录不拦截
                //为了方便,可以在登录的路径中不添加用户相关的标识"api",就可以不用配置不拦截的路径了
    }

}
